<%@ page import="org.apache.commons.mail.SimpleEmail" %>
<%@ page import="org.apache.commons.mail.EmailException" %>

<%@page import="connect.Login"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<style>
@import url(http://fonts.googleapis.com/earlyaccess/nanumgothic.css);
#maintot{
	padding-top:30px;/*위에 칸을 띄우는 것*/	
}
#mainbox{
	width:700px;
	height:700px;
	/*border:1px solid #faa719;*/
	margin:0 auto;
	margin-bottom: 50px;
}
#top{
	width:100%;
	height:50px;
	color:#000000;
	font-size:37px;
	font-family: 'Nanum Gothic', sans-serif;
	padding-top:10px;/*위에 칸을 띄우는 것*/

	text-shadow:1px 1px 1px #A4A4A4;
	font-weight: bolder;

	
}
#top2{
	border:3px solid #faa719;
}
#center{
	position:absolute;
}
#cent1{
	width:300px;
	height:100px;
	/*border:1px solid #faa719;*/
	position:absolute;
	top:100px;
	left:50px;
	background-image:url(./image/hta.logo.jpg);
	background-repeat:no-repeat;
	background-size:100% 100%;
	
}
#cent2{
	width:600px;
	height:350px;
	border:5px solid #faa719;
	position:absolute;
	top:210px;
	left:50px;
	
	border-top-right-radius:30px;
	border-bottom-right-radius:30px;
	border-top-left-radius:30px;
	border-bottom-left-radius:30px;
}
#cent22{
	width:500px;
	height:250px;
	/*border:1px solid #faa719;*/
	position:absolute;
	top:13%;
	left:8%;
}
#nameTot{
	width:400px;
	height:50px;
	font-size:22px;
	font-family: 'Nanum Gothic', sans-serif;
	/*border:3px solid #faa719;*/
	position:absolute;
}
#idname{
	width:150px;
	height:20px;
	/*border:3px solid #faa719;*/
	position:absolute;
	margin-left:73px;
	
	font-family: 'Nanum Gothic', sans-serif;
	font-size:20px;
	color:#faa719;
}
#memberNumTot{
	width:540px;
	height:50px;
	font-size:22px;
	font-family: 'Nanum Gothic', sans-serif;
	/*border:3px solid #faa719;*/
	position:absolute;
	top:70px;
}
#firstNumber{
	width:150px;
	height:20px;
	margin-left:44px;
	/*border:3px solid #faa719;*/
	
	font-family: 'Nanum Gothic', sans-serif;
	font-size:20px;
	color:#faa719;
}
#secondNumber{
	width:150px;
	height:20px;
	/*border:3px solid #faa719;*/

	font-family: 'Nanum Gothic', sans-serif;
	font-size:20px;
	color:#faa719;
}
#emailTot{
	width:540px;
	height:50px;
	font-size:22px;
	font-family: 'Nanum Gothic', sans-serif;
	/*border:3px solid #faa719;*/
	position:absolute;
	top:140px;
}
#email1{
	width:150px;
	height:20px;
	margin-left:14px;
	/*border:3px solid #faa719;*/

	font-family: 'Nanum Gothic', sans-serif;
	font-size:20px;
	color:#faa719;
}
#email2{
	width:150px;
	height:20px;
	/*border:3px solid #faa719;*/

	font-family: 'Nanum Gothic', sans-serif;
	font-size:20px;
	color:#faa719;
}
#mun{
	margin-top:70px;
	margin-left:90px;
	
	text-shadow:1px 1px 1px #A4A4A4;
	font-weight: bolder;
}
#mun1{
	margin-top:70px;
	margin-left:70px;
	
	text-shadow:1px 1px 1px #A4A4A4;
	font-weight: bolder;
}
#buttonTot{
	margin-top:20px;
	width:500px;
	height:60px;
	
	/*border:3px solid #faa719;*/
	position:absolute;
	top:210px;
	left:100px
}
#check{
	margin-left:1px;
	width:140px;
	height:40px;
	background-color: #faa719;
	font-family: 'Nanum Gothic', sans-serif;
	font-size:18px;
	color:#000000;
}
#check1{
	margin-left:30px;
	width:140px;
	height:40px;
	background-color: #faa719;
	font-family: 'Nanum Gothic', sans-serif;
	font-size:18px;
	color:#000000;
}
#check2{
	margin-left:80px;
	width:140px;
	height:40px;
	background-color: #faa719;
	font-family: 'Nanum Gothic', sans-serif;
	font-size:18px;
	color:#000000;
}
#check,#check1,#check2{
	border-top-right-radius:5px;
	border-bottom-right-radius:5px;
	border-top-left-radius:5px;
	border-bottom-left-radius:5px;
	box-shadow:4px 3px 6px #dddddd;
	border:1px solid #faa719;
	
	text-shadow:1px 1px 1px #DF7401;
	font-weight: bolder;
}

</style>
</head>
<body>
<jsp:useBean id="bean" class="connect.Login" scope="page"/>
<!-- form으로 받아온값을 bean id에 저장하고 class connet..에 값을 보낸다, scope page는 현재 페이지 -->
<jsp:setProperty property="*" name="bean"/><!--property 모든것을 가져와 name=bean에 저장한다 -->
<%
Login m=new Login();
m.setMid(bean.getMid());
m.setBirth(bean.getBirth());
m.setEmail1(bean.getEmail1());
m.setEmail2(bean.getEmail2());
m.setEmailTot(bean.getEmail1()+"@"+bean.getEmail2());
Login m1=m.searchpwd();


%>

<div id='maintot'>
	<div id='mainbox'>
		<div id='top'>
			&nbsp;&nbsp;비 밀 번 호 &nbsp;&nbsp;찾 기
			<hr id='top2'>
		</div>
		<div id='center'>
			<div id='cent1'>
			</div>
			<div id='cent2'>
				<div id='cent22'>
					<%
					if(m1.getPwd().equals("")){%>
					<div id='mun'><font color='red' face='Nanum Gothic' size='6'>찾는 비밀번호가 없습니다.</font></div>
					<div id='buttonTot'>
						<a href='index.jsp?inc_contents=IdSearch.jsp'><input type='button' id='check' value='아이디 찾기'></a>
						<a href='index.jsp?inc_contents=pawSearch.jsp'><input type='button' id='check1' value='비밀번호 찾기'></a>
					</div>
					<%}else{%>
					<%
					String id_pwd=m1.getPwd();//db에서 가져올 패스워드
					String username="중앙hta";//보내는 이름

					SimpleEmail email = new SimpleEmail(); // 선언을 한다

					email.setCharset("UTF-8");     // 인코딩을 설정한다.
					email.setHostName("smtp.gmail.com");
					email.setSmtpPort(456);
					email.setSSL(true);
					email.setTLS(true);
					email.setFrom("jiknet20@gmail.com", username); //보내는 사람			
					email.setAuthentication("jiknet20", "dlsry3099"); //SMTP 인증 (보내는 사람 계정의 아이디와 패스워드)				
					email.addTo(m1.getEmailTot(), m1.getMid()); //받는사람			
					email.setSubject("중앙hta에서 메일을 보내드립니다."); //메일 제목		
					email.setMsg("당신의 비밀번호는["+ id_pwd+"]입니다."); //메일 내용			
					email.send(); //메일 발송
					
					%>
						<div id='mun1'><font color='#0404B4' face='Nanum Gothic' size='5'>비밀번호를 이메일로 전송했습니다.</font> </div>
					<div id='buttonTot'>
						<a href='index.jsp?inc_contents=login.jsp'><input type='button' id='check2' value='로그인 하기'></a>
					</div>
					<%}%>
					
					
				</div>
				
			</div><!-- cent2 -->
		</div>
	</div>
</div>